//
// rRNA removal subworkflow options
//

process {

    withName: 'SORTMERNA' {
        ext.args  = '--index 0'
    }
    withName: 'SORTMERNA_INDEX' {
        ext.args  = '--index 1'
    }
    withName: 'RIBODETECTOR' {
        ext.prefix = { "${meta.id}.ribodetector" }
        ext.args = '--seed 1'
    }
    withName: 'BOWTIE2_ALIGN' {
        ext.prefix = { "${meta.id}.bowtie2_rrna" }
        ext.args = '--very-sensitive-local --seed 1 --reorder'
    }
    withName: 'BOWTIE2_ALIGN_PE' {
        ext.prefix = { "${meta.id}.bowtie2_rrna" }
        ext.args = '--very-sensitive-local --seed 1 --reorder'
    }
    withName: 'SAMTOOLS_VIEW_BOWTIE2' {
        ext.prefix = { "${meta.id}.bowtie2_unmapped" }
        ext.args = '-f 12'  // Keep only pairs where BOTH mates are unmapped
    }
    withName: 'SAMTOOLS_FASTQ_BOWTIE2' {
        ext.prefix = { "${meta.id}.bowtie2_filtered" }
    }
    withName: 'SEQKIT_REPLACE' {
        ext.args = '--pattern "^(.+)" --replacement "{fbn}_\\$1"'
        ext.prefix = { "${meta.id}_prefixed" }
    }
    withName: 'SEQKIT_REPLACE_U2T' {
        ext.args = '--by-seq --pattern "[Uu]" --replacement "T"'
        ext.prefix = { "${meta.id}_converted" }
    }
}
